import { Divider } from "antd"
import {Suspense} from "react"
import { Route, Routes, Navigate, BrowserRouter } from 'react-router-dom'
import routerlist from "./routerConfig"
let RouterView = ()=>{
    let renderRouter = (routerlist)=>{
       
        return routerlist.map((item,index)=>{
            return item.path ? <Route key={index} path={item.path} element={<item.component></item.component>}>
                {
                    item.children && renderRouter(item.children)
                }
            </Route>:
            <Route key={index} path={item.from} element={<Navigate to={item.to}></Navigate>}></Route>
        })
    }
   
    return (
       
        <BrowserRouter>
            <Suspense fallback={<div>...loading</div>}>
                <Routes>
                    {
                        renderRouter(routerlist)
                    }
                </Routes>
            </Suspense>
        </BrowserRouter>
    )
}
export default RouterView